package io.finer.erp.jeecg.finance.mapper;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import io.finer.erp.jeecg.bas.vo.SalesDeliveryOrEntryVO;
import io.finer.erp.jeecg.finance.dto.DeliveryDTO;
import io.finer.erp.jeecg.finance.dto.FinaReceiptDto;
import io.finer.erp.jeecg.finance.dto.ZrkShoporderDto;
import io.finer.erp.jeecg.finance.entity.FinaReceipt;
import io.finer.erp.jeecg.finance.vo.DeliverDetalidVO;
import io.finer.erp.jeecg.finance.vo.DeliverySumVO;
import io.finer.erp.jeecg.finance.vo.DeliverySummaryVO;
import io.finer.erp.jeecg.finance.vo.FinaPaymentPage;
import io.finer.erp.jeecg.finance.vo.FinaReceiptPage;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSKVo;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSumPage;
import io.finer.erp.jeecg.finance.vo.FinaReceiptSumVO;
import io.finer.erp.jeecg.finance.vo.ReceiptSumVO;

/**
 * @Description: 收款表
 * @Author: jeecg-boot
 * @Date:   2021-03-22
 * @Version: V1.0
 */
public interface FinaReceiptMapper extends BaseMapper<FinaReceipt> {

    /*
     * 应收/已收
     * @author libaow
     * @date 2021/4/22 16:12
     * @param page
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     */
    List<FinaReceiptPage> getReceiptPage(@Param("createTimeStart")String createTimeStart,
                                         @Param("createTimeEnd")String createTimeEnd,
                                         @Param("customerName")String customerName,
                                         @Param("receivablesEnd")BigDecimal receivablesEnd,@Param("receivablesStart")BigDecimal receivablesStart,
                                         @Param("receivedsEnd")BigDecimal receivedsEnd,@Param("receivedsStart")BigDecimal receivedsStart,
                                         @Param("discountSumPriceEnd")BigDecimal discountSumPriceEnd,@Param("discountSumPriceStart")BigDecimal discountSumPriceStart,
                                        @Param("invoicePriceEnd")BigDecimal invoicePriceEnd ,@Param("invoicePriceStart")BigDecimal invoicePriceStart
                                        ,@Param("cashType")String cashType);


    /*
     * 应收/已收列表金额合计
     * @author libaow
     * @date 2021/4/22 16:12
     * @param page
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     */
    List<FinaReceiptPage> getReceiptPageSum(
                                         @Param("createTimeStart")String createTimeStart,
                                         @Param("createTimeEnd")String createTimeEnd,
                                         @Param("customerName")String customerName,
                                         @Param("receivablesEnd")BigDecimal receivablesEnd,@Param("receivablesStart")BigDecimal receivablesStart,
                                         @Param("receivedsEnd")BigDecimal receivedsEnd,@Param("receivedsStart")BigDecimal receivedsStart,
                                         @Param("discountSumPriceEnd")BigDecimal discountSumPriceEnd,@Param("discountSumPriceStart")BigDecimal discountSumPriceStart,
                                         @Param("invoicePriceEnd")BigDecimal invoicePriceEnd ,@Param("invoicePriceStart")BigDecimal invoicePriceStart);


    FinaReceiptPage getTotalOwed(@Param("customerId")String customerId, @Param("customerName")String customerName,
                                 @Param("createTimeStart")String createTimeStart);


    /*
     * 收款汇总
     * @author libaow
     * @date 2021/4/22 16:12
     * @param page
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     */
    Page<FinaReceiptSumPage> getReceiptSumPage(IPage<FinaReceiptSumPage> page,
                                               @Param("createTimeStart")String createTimeStart,
                                               @Param("createTimeEnd")String createTimeEnd,
                                               @Param("customerName") String customerName);

    /*
     *  收款单
     * @author libaow
     * @date 2021/4/22 16:13
     * @param page
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     */
    Page<FinaReceiptSKVo> getReceiptSKPage(IPage<FinaReceiptSKVo> page,
                                           @Param("createTimeStart")Date createTimeStart,
                                           @Param("createTimeEnd")Date createTimeEnd,
                                           @Param("customerName")String customerName,
                                           @Param("cashType")String cashType,
                                           @Param("map")Map<String, Object> map);


    /**
     * @Description 导出Excel使用
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     * @return
     * Create at: 2021-05-25 09:08:32
     * @author: duany
     * Revision:
     *    2021-05-25 09:08:32 - first revision by duany
     *        
     */
    List<FinaReceiptSKVo> excelGet(@Param("createTimeStart")Date createTimeStart, @Param("createTimeEnd")Date createTimeEnd, @Param("customerName")String customerName);


    /**
     * 默认导出当天的应收已收统计信息
     * @param createTimeStart
     * @param createTimeEnd
     * @param customerName
     * @return
     */
    List<FinaReceiptDto> getReceiptExcel(@Param("createTimeStart")String createTimeStart,
                                         @Param("createTimeEnd")String createTimeEnd,
                                         @Param("customerName")String customerName);


    /*
     * 统计本月的金额
     * @author libaow
     * @date 2021/4/16 10:21
     * @return java.util.List<io.finer.erp.jeecg.finance.vo.FinaReceiptVO>
     */
    FinaReceiptSumVO getAmount(@Param("createTimeStart")Date createTimeStart,
                               @Param("createTimeEnd")Date createTimeEnd,
                               @Param("customerName")String customerName,
                               @Param("cashType")String cashType,
                               @Param("map")Map<String, Object> map);

    ReceiptSumVO getAmountSum(@Param("createTimeStart")String createTimeStart,
                              @Param("createTimeEnd")String createTimeEnd,
                              @Param("customerName")String customerName);


    /*
     * 发货汇总信息---出入库查询
     * @author libaow
     * @date 2021/4/22 16:11
     * @param startTime
     * @param endTime
     * @param categoryId
     */
    List<DeliverySummaryVO> getDeliver(@Param("startTime") String startTime,
                                       @Param("endTime") String endTime,
                                       @Param("categoryIds")String[] categoryIds);

    /*
     * 发货汇总信息---发货单查询
     * @author libaow
     * @date 2021/4/27 16:18
     * @param startTime
     * @param endTime
     * @param categoryIds
     */
    List<DeliverySummaryVO> getDelivers(@Param("startTime") String startTime,
                                       @Param("endTime") String endTime,
                                       @Param("categoryIds")String[] categoryIds);
    /*
     * 发货汇总信息
     * @author libaow
     * @date 2021/4/22 16:11
     * @param startTime
     * @param endTime
     * @param categoryId
     */
    DeliverySumVO getDeliverSum(@Param("startTime") String startTime,
                                       @Param("endTime") String endTime,
                                       @Param("categoryIds")String[] categoryIds);


    /*
     * 发货明细汇总单信息
     * @author libaow
     * @date 2021/4/28 8:40
     * @param detalidVO
     */
    List<DeliverDetalidVO> getDeliverDetali(@Param("customerIds") String[] customerIds,
                                            @Param("startTime")String startTime,
                                            @Param("endTime")String endTime, @Param("categoryName")String categoryName);


    List<ZrkShoporderDto> getOrderByHxStatus(@Param("customerId")String customerId);

    List<ZrkShoporderDto> getOrderByHxStatusY(@Param("customerId")String customerId);

    List<SalesDeliveryOrEntryVO> getDeliveryOrEntry(@Param("customerId") String customerId,
                                                    @Param("startTime") String startTime,
                                                    @Param("endTime") String endTime,
                                                    @Param("salesType")Integer salesType,
                                                    @Param("code")String code,
                                                    @Param("productName")String productName,
                                                    @Param("viceQtyStart")Integer viceQtyStart,
                                                    @Param("viceQtyEnd")Integer viceQtyEnd,
                                                    @Param("qtyStart")BigDecimal qtyStart,
                                                    @Param("qtyEnd")BigDecimal qtyEnd,
                                                    @Param("unitPriceStart")BigDecimal unitPriceStart,
                                                    @Param("unitPriceEnd")BigDecimal unitPriceEnd,
                                                    @Param("totalPriceStart")BigDecimal totalPriceStart,
                                                    @Param("totalPriceEnd")BigDecimal totalPriceEnd,
                                                    @Param("totalAmountStart")BigDecimal totalAmountStart,
                                                    @Param("totalAmountEnd")BigDecimal totalAmountEnd,
                                                    @Param("hxPriceStart")BigDecimal hxPriceStart,
                                                    @Param("hxPriceEnd")BigDecimal hxPriceEnd,
                                                    @Param("zkPriceStart")BigDecimal zkPriceStart,
                                                    @Param("zkPriceEnd")BigDecimal zkPriceEnd,
                                                    @Param("qkPriceStart")BigDecimal qkPriceStart,
                                                    @Param("qkPriceEnd")BigDecimal qkPriceEnd,
                                                    @Param("remark")String remark);

    List<SalesDeliveryOrEntryVO> getDeliveryQkPrice(@Param("customerId") String customerId,
            @Param("startTime") String startTime,
            @Param("endTime") String endTime,
            @Param("salesType")Integer salesType,
            @Param("code")String code,
            @Param("productName")String productName,
            @Param("viceQtyStart")Integer viceQtyStart,
            @Param("viceQtyEnd")Integer viceQtyEnd,
            @Param("qtyStart")BigDecimal qtyStart,
            @Param("qtyEnd")BigDecimal qtyEnd,
            @Param("unitPriceStart")BigDecimal unitPriceStart,
            @Param("unitPriceEnd")BigDecimal unitPriceEnd,
            @Param("totalPriceStart")BigDecimal totalPriceStart,
            @Param("totalPriceEnd")BigDecimal totalPriceEnd,
            @Param("totalAmountStart")BigDecimal totalAmountStart,
            @Param("totalAmountEnd")BigDecimal totalAmountEnd,
            @Param("hxPriceStart")BigDecimal hxPriceStart,
            @Param("hxPriceEnd")BigDecimal hxPriceEnd,
            @Param("zkPriceStart")BigDecimal zkPriceStart,
            @Param("zkPriceEnd")BigDecimal zkPriceEnd,
            @Param("qkPriceStart")BigDecimal qkPriceStart,
            @Param("qkPriceEnd")BigDecimal qkPriceEnd,
            @Param("remark")String remark);

    List<SalesDeliveryOrEntryVO> getDeliveryReceivables(@Param("customerId") String customerId,
											            @Param("startTime") String startTime,
											            @Param("endTime") String endTime,
											            @Param("salesType")Integer salesType,
											            @Param("code")String code,
											            @Param("productName")String productName,
											            @Param("viceQtyStart")Integer viceQtyStart,
											            @Param("viceQtyEnd")Integer viceQtyEnd,
											            @Param("qtyStart")BigDecimal qtyStart,
											            @Param("qtyEnd")BigDecimal qtyEnd,
											            @Param("unitPriceStart")BigDecimal unitPriceStart,
											            @Param("unitPriceEnd")BigDecimal unitPriceEnd,
											            @Param("totalPriceStart")BigDecimal totalPriceStart,
											            @Param("totalPriceEnd")BigDecimal totalPriceEnd,
											            @Param("totalAmountStart")BigDecimal totalAmountStart,
											            @Param("totalAmountEnd")BigDecimal totalAmountEnd,
											            @Param("hxPriceStart")BigDecimal hxPriceStart,
											            @Param("hxPriceEnd")BigDecimal hxPriceEnd,
											            @Param("zkPriceStart")BigDecimal zkPriceStart,
											            @Param("zkPriceEnd")BigDecimal zkPriceEnd,
											            @Param("qkPriceStart")BigDecimal qkPriceStart,
											            @Param("qkPriceEnd")BigDecimal qkPriceEnd,
											            @Param("remark")String remark);
    
    IPage<SalesDeliveryOrEntryVO> selectSalesDeliveryAndEntry(Page<SalesDeliveryOrEntryVO> page, @Param("customerName") String customerName,
												            @Param("startTime") String startTime,
												            @Param("endTime") String endTime,
												            @Param("salesType")Integer salesType,
												            @Param("code")String code,
												            @Param("productName")String productName,
												            @Param("viceQtyStart")Integer viceQtyStart,
												            @Param("viceQtyEnd")Integer viceQtyEnd,
												            @Param("qtyStart")BigDecimal qtyStart,
												            @Param("qtyEnd")BigDecimal qtyEnd,
												            @Param("unitPriceStart")BigDecimal unitPriceStart,
												            @Param("unitPriceEnd")BigDecimal unitPriceEnd,
												            @Param("totalPriceStart")BigDecimal totalPriceStart,
												            @Param("totalPriceEnd")BigDecimal totalPriceEnd,
												            @Param("totalAmountStart")BigDecimal totalAmountStart,
												            @Param("totalAmountEnd")BigDecimal totalAmountEnd,
												            @Param("hxPriceStart")BigDecimal hxPriceStart,
												            @Param("hxPriceEnd")BigDecimal hxPriceEnd,
												            @Param("zkPriceStart")BigDecimal zkPriceStart,
												            @Param("zkPriceEnd")BigDecimal zkPriceEnd,
												            @Param("qkPriceStart")BigDecimal qkPriceStart,
												            @Param("qkPriceEnd")BigDecimal qkPriceEnd,
												            @Param("remark")String remark,
												            @Param("customerIds")String[] customerIds);
    
    List<DeliveryDTO> getDeliveryEntry(@Param("customerId")String customerId);


	List<DeliveryDTO> getDeliveryEntryAndId(@Param("customerId")String customerId
			, @Param("entryIdList")List<String> entryIdList);
	
	/**
	 * @Description 期初未开票
	 * @param supplierId
	 * @param supplierName
	 * @param createTimeStart
	 * @return
	 * Create at: 2021-06-22 18:00:36
	 * @author: xzs
	 * Revision:
	 *    2021-06-22 18:00:36 - first revision by xzs
	 *
	 */
	FinaReceiptPage getNoneInvoice(@Param("customerId")String customerId, @Param("customerName")String customerName, 
            @Param("createTimeStart")String createTimeStart);
}